<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../resources/js-test.js"></script>
<script src="test.js"></script>
</head>
<body>
<div id="console"></div>

<script>
    function nsResolver(prefix) {
        if (prefix == 'bar')
            return 'http://foo.com';
        return null;
    }

    function nodeInResult(node, result) {
        for (i=0; i < result.snapshotLength; ++i)
            if (result.snapshotItem(i) == node)
                return true;
        return false;
    }

    result = DOM.evaluate("//*", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    shouldBe("nodeInResult(ROOT, result)", "true");

    result = DOM.evaluate("//bar:CHILD3", ROOT, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    shouldBe("nodeInResult(ROOT, result)", "false");
    shouldBe("nodeInResult(CHILD1, result)", "false");
    shouldBe("nodeInResult(CHILD3, result)", "true");

    result = DOM.evaluate("//bar:*", ROOT, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    shouldBe("nodeInResult(ROOT, result)", "false");
    shouldBe("nodeInResult(CHILD1, result)", "false");
    shouldBe("nodeInResult(CHILD3, result)", "true");

    result = DOM.evaluate("//node()", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    shouldBe("nodeInResult(ROOT, result)", "true");
    shouldBe("nodeInResult(TEXT1, result)", "true");

    result = DOM.evaluate("//text()", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    shouldBe("nodeInResult(ROOT, result)", "false");
    shouldBe("nodeInResult(TEXT1, result)", "true");

    result = DOM.evaluate("//comment()", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    shouldBe("nodeInResult(ROOT, result)", "false");
    shouldBe("nodeInResult(COMMENT, result)", "true");

    result = DOM.evaluate("//processing-instruction()", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    shouldBe("nodeInResult(ROOT, result)", "false");
    shouldBe("nodeInResult(PI, result)", "true");

    result = DOM.evaluate("//processing-instruction('xml-stylesheet')", ROOT, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    shouldBe("nodeInResult(PI, result)", "true");
    shouldBe("nodeInResult(PI2, result)", "false");

</script>
</body>
</html>
